#ifndef SCROLLTEXT_H
#define SCROLLTEXT_H

#include <QWidget>
#include <QDebug>
#include <QMouseEvent>
#include <QPainter>
#include <QPropertyAnimation>

class ScrollText : public QWidget
{
    Q_OBJECT
    //Q_PROPERTY(int deviation READ readDeviation WRITE setDeviation)
public:
    explicit ScrollText(QWidget *parent = nullptr);
    explicit ScrollText(const QStringList & textList, QWidget * parent = nullptr);

    void setScrollTextList(const QStringList & textList);
    void setCurrentIndex(int index);
    int getCurrentIndex(void);
    //void setCurrentText(const QString & Text);
    //QString getCurrentText(void);

signals:
    void scrollFinishSign(void);

protected:
    void mousePressEvent(QMouseEvent *event);
    void mouseMoveEvent(QMouseEvent *event);
    void mouseReleaseEvent(QMouseEvent *event);
    void paintEvent(QPaintEvent *event);
    int readDeviation(void);
    void setDeviation(int n);

private:
    void paintText(QPainter & painter, int index, int deviation);
    void paintLine(QPainter &painter);
    void homing(void);

private:
    QStringList m_textList;

    bool m_isDragging;
    int m_mouseSrcPos;
    int m_currentIndex;
    int m_deviation;
    QPropertyAnimation * m_homingAni;
};

#endif // SCROLLTEXT_H
